

<html>
  <%
def access = session.access
access.refresh()
def areaList = access.getList("area")
def employeeList = access.getList("employee")
def roleList = Role.findAllByLevelNot("0")
%>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="layout" content="main" />
        <title>Create Access</title>         
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><a class="home" href="${resource(dir:'')}">Home</a></span>
            <span class="menuButton"><g:link class="list" action="list">Access List</g:link></span>
        </div>
        <div class="body">
            <h1>Create Access</h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <g:hasErrors bean="${accessInstance}">
            <div class="errors">
                <g:renderErrors bean="${accessInstance}" as="list" />
            </div>
            </g:hasErrors>
            <g:form action="save" method="post" >
                <div class="dialog">
                    <table>
                        <tbody>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="userName">User Name:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:accessInstance,field:'userName','errors')}">
                                    <input type="text" id="userName" name="userName" value="${fieldValue(bean:accessInstance,field:'userName')}"/>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="password">Password:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:accessInstance,field:'password','errors')}">
                                    <input type="password" id="password" name="password" value="${fieldValue(bean:accessInstance,field:'password')}"/>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="area">Area:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:accessInstance,field:'area','errors')}">
                                    <g:select optionKey="id" from="${areaList}" name="area.id" value="${accessInstance?.area?.id}" ></g:select>
                                </td>
                            </tr> 
                            <g:if test="${access.hasDevAuth()}"
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="container">Container:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:accessInstance,field:'container','errors')}">
                                    <g:select optionKey="id" from="${Container.list()}" name="container.id" value="${accessInstance?.container?.id}" ></g:select>
                                </td>
                            </tr> 
                            </g:if>
                            <g:else>
                              <input type="hidden" name="container.id" value="${access.container.id}"
                            </g:else>
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="emp">Emp:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:accessInstance,field:'emp','errors')}">
                                    <g:select optionKey="id" from="${employeeList}" name="emp.id" value="${accessInstance?.emp?.id}" ></g:select>
                                </td
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="role">Role:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:accessInstance,field:'role','errors')}">
                                    <g:select optionKey="id" from="${roleList}" name="role.id" value="${accessInstance?.role?.id}" ></g:select>
                                </td>
                            </tr> 
                        
                        </tbody>
                    </table>
                </div>
                <div class="buttons">
                    <span class="button"><input class="save" type="submit" value="Create" /></span>
                </div>
            </g:form>
        </div>
    </body>
</html>
